<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<%java.util.Random r=new java.util.Random();  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/calendar.js"></script>
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/business/contractcase.js"></script>
<script type="text/javascript" language="javascript">
$(function(){
	// 隐CANG所有子CASE...
	   $("tr [id^='sub_']").hide();
});

function showSubCase(ahref,obj){
	if($($(ahref).children()[0]).text()=='(+)'){
		$("tr [id^='sub_"+obj+"']").show();
		$($(ahref).children()[0]).text('(-)');
	}
	else {
		$($(ahref).children()[0]).text('(+)');
		$("tr [id^='sub_"+obj+"']").hide();
	}
}
function processOrViewCase(){
	if(checkCurrentForm()){
		var objs = document.getElementsByName("id");
		var id = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != 0 && objs[i].checked){
				id = objs[i].value;
				break;
			}
		}
		var isDept = $("#isDept").val();
		window.location.href = "./contract.do?action=processOrViewContractCase&id="+id+"&isDept="+isDept;
		window.location.target = "main";
	}
}
</script>
</head>
<body>
<form name="deptContractForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
					<c:choose>
					 <c:when test="${isDept==1}">
					        <td class="title_lab">部门所有案件</td>
					 </c:when>
					 <c:otherwise>
					        <td class="title_lab">我的案件</td>
					 </c:otherwise>
					</c:choose>
						
					</tr>
					<tr>
						<td valign="bottom" class="a_tools" style="padding-left: 3px;">客户关键字：
							<input id="customerName" name="customerName" class="input_query" type="text" value="${customerName}"/>
							<input id="sFlag" name="sFlag" type="hidden" value="${sFlag}"/>
							<a class="search" href="javascript:searchContract();" title="" hidefocus="true">查询</a>
							|<a class="asearch" href="javascript:advancedQueryDialog();" target="main" hidefocus="true">高级查询</a>
							<!--  暂时功能  -->
							|
							<a class="invoice" href="javascript:processOrViewCase();" title="查看或处理" hidefocus="true" >查看或处理</a>
							|
							<a class="invoice" href="#" title="案件取消 hidefocus="true" >案件取消</a>							
							|
							<a class="update" href="#" title="案件恢复" hidefocus="true">案件恢复</a>
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
							<c:choose>
								<c:when test="${isDept==1}">
									<td class="title_lab">部门所有案件</td>
								</c:when>
								<c:otherwise>
									<td class="title_lab">我的案件</td>
								</c:otherwise>
							</c:choose>
							<td align="right" valign="">
							<!-- page -->
							<table class="table_page2">
								<tr>
									<td valign="bottom">
										<img src="./images/frist.bmp" onclick="pageContract(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/last.bmp" onclick="pageContract(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
										<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
										<img src="./images/next.bmp" onclick="pageContract(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/end.bmp" onclick="pageContract(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
										共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>&nbsp;&nbsp;&nbsp;
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr><td colspan="3" height="2"></td></tr>
					<tr>
						<td valign="top" colspan="2">
							<table class="table">
								<tr>
									<td valign="top">
										<table class="table_style">
											<tr>
												<td class="title" width="8"></td>
												<td class="title" width="30">选择</td>
												<td class="title" width="20"></td>
												<td class="title">案号</td>
												<td class="title">申请号</td>
												<td class="title">合同号</td>
												<td class="title">申请人</td>
												<td class="title">销售代表</td>
												<td class="title">立案日</td>
												<td class="title">申请日</td>
												<td class="title">当前状态 </td>
												<td class="title">当前状态天数</td>
												<td class="title">距期限天数</td>
												<!-- 
												<td class="title">客户名称</td>
												 -->
											</tr>
											<c:forEach var="case" items="${caseList}">
											<tr id="${case.mark}" onmouseover="onmousemoveChange(this,'img${case.caseCode},${case.caseId}')" onmouseout="onmouseoutChange(this,'img${case.caseCode},${case.caseId}')">
												<td height="16" width="8" align="right"><img id="img${case.caseCode},${case.caseId}" src="./images/table_sign2.bmp"></td>
												<td align="center">
												     <c:if test="${case.isSub==0}">
												    <input id="id" name="id" type="checkbox" value="${case.caseCode},${case.caseId},${case.applyPersonId},${userId}"/>
											      	</c:if>
												</td>
												<td>	
												    <c:if test="${case.isSub==0 and case.hasSub==1}">
												       <a href='#' onclick="showSubCase(this,'${case.mark}')"><font color='blue'>(+)</font></a>
												    </c:if>
												</td>
												
												<td> ${case.caseCode}</td>
												<td><a href="./contract.do?action=contractDetail&sign=5&id=${case.caseCode},${case.caseId}" target="main">${case.applicationCode}</a></td>
												<td align="left">${case.contractCode}</td>
												<td>
												${case.applyName}
												</td>
												<td>${case.saleName}</td>
												<td>${case.applicationDate}</td>
												<td>${case.applicationDate}</td>
												<td>${case.processName}</td>
												<td>${case.currentStatusDay}</td>
												<td>${case.deadLineLeft}</td>
												<td style="display:none;">
												     <input type="hidden" id="hasSub" value="${case.hasSub}"> 
												     <input type="hidden" id="isSub" value="${case.isSub}">
												     <input type="hidden" id="applyPersonId" value="${case.applyPersonId}"> 
												     
												</td>
												<!-- 
												<td align="left">${contract.customerName}</td>
												 -->
											</tr>
											</c:forEach>
										</table>
									</td>
								</tr>
								<tr>
									<td align="left" valign="bottom">
										<!-- page -->
										<table id="tp" class="table_page">
											<tr>
												<td>&nbsp;&nbsp;
													<img src="./images/frist.bmp" onclick="pageContract(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
													<img src="./images/last.bmp" onclick="pageContract(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
													<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
													<img src="./images/next.bmp" onclick="pageContract(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
													<img src="./images/end.bmp" onclick="pageContract(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
													共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<!-- <input id="contractCode" name="contractCode" type="hidden" value="${queryContract.contractCode}"/>
	<input id="customerName2" name="customerName2" type="hidden" value="${queryContract.customerName2}"/>
	<input id="startContractCost" name="startContractCost" type="hidden" value="${queryContract.startContractCost}"/>
	<input id="endContractCost" name="endContractCost" type="hidden" value="${queryContract.endContractCost}"/>
	<input id="purchaseDesc" name="purchaseDesc" type="hidden" value="${queryContract.purchaseDesc}"/>
	<input id="startContractDate" name="startContractDate" type="hidden" value="${queryContract.startContractDate}"/>
	<input id="endContractDate" name="endContractDate" type="hidden" value="${queryContract.endContractDate}"/>
	<input id="startBackCost" name="startBackCost" type="hidden" value="${queryContract.startBackCost}"/>
	<input id="endBackCost" name="endBackCost" type="hidden" value="${queryContract.endBackCost}"/>
	<input id="invoiceDesc" name="invoiceDesc" type="hidden" value="${queryContract.invoiceDesc}"/>
	<input id="salePersonId" name="salePersonId" type="hidden" value="${queryContract.salePersonId }"/> -->
	<input id="userId" name="userId" type="hidden" value="${userId}"/>
	<input id="sFlag" name="sFlag" type="hidden" value="${sFlag}"/>
	<input id="isDept" name="isDept" type="hidden" value="${isDept}"/>
</form>
</body>
</html>